package com.ctshk.rpc.finance.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.finance.dto.advance.AdvancePaymentRefundDTO;
import com.ctshk.rpc.finance.entity.FinanceAdvancePaymentRefund;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 财务退预收款表 Mapper 接口
 * </p>
 *
 * @author 谢涛
 * @since 2021-03-23
 */
public interface FinanceAdvancePaymentRefundMapper extends BaseMapper<FinanceAdvancePaymentRefund> {

    /**
     * 退预收记录详情
     * @param refundId
     * @return
     */
    @Select("SELECT a.refund_money_amount,a.refund_unavailable_amount,a.refund_available_amount,a.currency,a.exchange_rate,a.refund_method_name,a.refund_account,a.refund_time,a.explains,a.approval_status,a.approval_id,a.file_json,a.create_id,\n" +
            "b.supplier_name,b.supplier_address,b.supplier_bank_card,b.supplier_bank_name,b.supplier_contacts,b.supplier_email,b.supplier_telephone,\n" +
            "c.money_amount,c.currency_id,c.currency AS sumCurrency,c.exchange_rate AS sumExchangeRate\n" +
            "FROM t_finance_advance_payment_refund a\n" +
            "LEFT JOIN t_finance_advance_payment b ON a.advance_payment_id = b.id\n" +
            "LEFT JOIN t_finance_advance_payment_apply_summary c ON a.supplier_id = c.supplier_id\n" +
            "WHERE a.id = #{id} AND a.is_deleted = 0 LIMIT 1")
    AdvancePaymentRefundDTO queryDetail(@Param("id") Long refundId);
}
